#########################################################################################
# 
# Models for Interethnic Relations
#
#########################################################################################

#########################################################################################
### Democratic Republic of Congo

# Indirect
congo$interethnic.z <- (congo$interethnic-mean(congo$interethnic, na.rm=T))/sd(congo$interethnic, na.rm=T)

int.drc <- ictreg.joint(Y ~ female + age.z + edu.z + income.z + hh_size.z +  murder_yes 
                          + terr_2 + terr_3 + terr_4 + terr_5 + terr_6,  
                          treat="treatment", 
                          outcome="interethnic.z",
                          outcome.reg="linear",
                          constrained=TRUE,
                          J=3, data=congo)
summary(int.drc)

# Direct
int.drc.direct <- lm(interethnic.z ~ direct + female + age.z + edu.z + income.z + hh_size.z +  murder_yes
          + terr_2 + terr_3 + terr_4 + terr_5 + terr_6, data=congo)

summary(int.drc.direct)

inter.congo.ind <- int.drc$par.outcome[13]
inter.congo.dir <- coef(int.drc.direct)[2]

inter.congo.ind.lo <- int.drc$par.outcome[13] - 1.64*int.drc$se.outcome[13]
inter.congo.dir.lo <- coef(int.drc.direct)[2] - 1.65*se.coef(int.drc.direct)[2]

inter.congo.ind.up <- int.drc$par.outcome[13] + 1.64*int.drc$se.outcome[13]
inter.congo.dir.up <- coef(int.drc.direct)[2] + 1.65*se.coef(int.drc.direct)[2]

#########################################################################################
### Liberia

# Indirect
int.lib <- ictreg.joint(Y ~ female + age.z + edu.z + income.z + hh_size.z + cw_kill +  as.factor(county), 
                          treat="treatment", 
                          outcome="trust1",
                          outcome.reg="linear",
                          constrained=TRUE,
                          J=3, data=liberia)
summary(int.lib)

# Direct
int.lib.direct <- lm(trust1 ~ direct.1 + female + age.z + edu.z + income.z + hh_size.z + cw_kill
          + county, data=liberia)

summary(int.lib.direct)

inter.liberia.ind <- int.lib$par.outcome[10]
inter.liberia.dir <- coef(int.lib.direct)[2]

inter.liberia.ind.lo <- int.lib$par.outcome[10] - 1.64*int.lib$se.outcome[10]
inter.liberia.dir.lo <- coef(int.lib.direct)[2] - 1.64*se.coef(int.lib.direct)[2]

inter.liberia.ind.up <- int.lib$par.outcome[10] + 1.64*int.lib$se.outcome[10]
inter.liberia.dir.up <- coef(int.lib.direct)[2] + 1.64*se.coef(int.lib.direct)[2]


#########################################################################################
### Sri Lanka

# Indirect
sri$outgrouptrust.z <- (sri$outgrouptrust - mean(sri$outgrouptrust, na.rm=T))/sd(sri$outgrouptrust, na.rm=T)

int.sri <- ictreg.joint(Y ~ female + age.z + edu.z + income.z + hh_size.z + killed + trauma +  as.factor(Province),
                          treat="treatment", 
                          outcome="outgrouptrust.z",
                          outcome.reg="linear",
                          constrained=TRUE,
                          J=3, data=sri)
summary(int.sri)


# Direct
int.sri.direct <- lm(outgrouptrust.z ~ direct.1 + female + age.z + edu.z +  income.z + hh_size.z + killed + trauma 
          + as.factor(Province), data=sri)

summary(int.sri.direct)

inter.sri.ind <- int.sri$par.outcome[16]
inter.sri.dir <- coef(int.sri.direct)[2]

inter.sri.ind.lo <- int.sri$par.outcome[16] - 1.64*int.sri$se.outcome[16]
inter.sri.dir.lo <- coef(int.sri.direct)[2] - 1.64*se.coef(int.sri.direct)[2]

inter.sri.ind.up <- int.sri$par.outcome[16] + 1.64*int.sri$se.outcome[16]
inter.sri.dir.up <- coef(int.sri.direct)[2] + 1.64*se.coef(int.sri.direct)[2]

#########################################################################################

